<?php $this->load->view("include/meta"); ?>
    <title>我的建议-打球吧</title>

    <!-- Bootstrap core CSS -->
    <link href="<?php echo site_url();?>assets/css/bootstrap.css" rel="stylesheet">
    <link href="<?php echo site_url();?>assets/css/common.css" rel="stylesheet">
    <link href="<?php echo site_url();?>assets/css/jquery-impromptu.css" rel="stylesheet">

  </head>

  <body class="gray-bg">

    <!-- Wrap all page content here -->
    <div id="wrap">

    <!-- header start -->
    <?php $this->load->view("include/header"); ?> 
    <!-- header end -->

    <div class="container" id="main">
        <div class="row" id="fillin" >
            <div class="col-md-6 col-md-push-3">

                <div class="panel panel-default">
                  <div class="panel-heading">
                    <h3 class="panel-title">意见反馈</h3>
                  </div>
                  <div class="panel-body">

                    <div class="form-group">
                        <textarea id="message" class="form-control" rows="4" placeholder="您的宝贵意见对我们非常重要" autocomplete="off"></textarea>
                    </div>

                    <div class="form-group">
                        <input type="email" class="form-control" id="email" placeholder="留下email方便我们与您交流" autocomplete="off" />
                    </div>

                    <div class="form-group">
                        <button id="suggest" type="submit" class="btn btn-primary">发表</button>
                    </div>

                  </div>
                </div>

            </div>

        </div>
    </div>    <!-- end content -->

    </div>    <!-- end wrap -->

    <!-- footer start -->
    <?php $this->load->view("include/footer"); ?> 
    <!-- footer end -->

    <script type="text/javascript" src="<?php echo site_url();?>assets/js/jquery.min.js"></script>
    <script type="text/javascript" src="<?php echo site_url();?>assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="<?php echo site_url();?>assets/js/jquery-impromptu.js"></script>
    <script>
    $(function(){

        $("div").data("enable",true);

        $('#suggest').click(function(){

            if(!$("div").data("enable")) 
            {
                return false;
            }
            else
            {
                $("div").data("enable",false);
            }

            $.ajax({
                url: "<?php echo site_url();?>api/user/suggest",
                type: "POST",
                dataType: "json",
                data: {email:$('#email').val(),message:$('#message').val()},
                success: function(data){
                    if(data.error == 0)
                    {
                        $.prompt('提交成功，感谢您的宝贵意见',{
                                buttons: { "确定": true },
                                fitMasker: true,
                                isButtonHide:true
                                });
                        setTimeout(function(){$.prompt.close();window.location.href= '<?php echo site_url();?>';},2000);
                    }
                    else
                    {
                        $.prompt(data.msg,{
                                buttons: { "确定": true },
                                fitMasker: true
                                });
                    }

                    $("div").data("enable",true);
                }
            });
        });

    });
    </script>
    </body>
</html>
